
function getcwCBSFPDAccount() {
    // 获取出版社对象
    var JIAFANG = $("#cbsfpd_addWinForm input[qucln='PUB_ID']").val();

    //如果修改出版社，则清空明细的数据
    $("#cbsfpd_addWinForm input[qucln='PUB_ID']").change(function(){
        $('#cbsfpd_addItemDatagrid').datagrid('loadData',{total:0,rows:[]});
    });

}


/**
 * *出版社发票单中：选择单据按钮事件
 */
function chooseDZCL(){
    // 获取供应商
    var PUB_ID=$('#cbsfpd_addWinForm').find('input[qucln=PUB_ID]').val();
    if (PUB_ID==''){
        $.messager.alert('提示','请选择出版社！');
        return;
    }
    _data_qw('cbst','ds_cw_pubInvoice_item2','cbsfpd_sure1','44','clowQuery','');
}

//选择单据弹出窗口的回调函数
function clowQuery(){
    $('#cbst_dataQuery').attr('onclick','clcjsQuery(this)');
}

//结算清单的选择单据的查询按钮
function clcjsQuery(obj){
    var prefix=$(obj).attr('pre');
    var dsId=$(obj).attr('dsid');
    var resultDG = 'DATA_DATALIST';
    var comUseConf='commUseD';
    var PUB_ID=$('#cbsfpd_addWinForm').find('input[qucln=PUB_ID]').val();
    var otherConfig = "1-PUB_ID-"+PUB_ID+"-inc|+";
    var comUse = parseConfig(prefix+"_"+comUseConf);
    var useConf = otherConfig+comUse;

    //获取对账明细的数据行
    var dzmxRows = $('#cbsfpd_addItemDatagrid').datagrid('getRows');
    var ids='';
    if(dzmxRows.length>0){
        for(var i=0,j=dzmxRows.length;i<j;i++){
            ids+="'"+dzmxRows[i].I_INFO+"',";
        }
        ids=ids.substring(0,ids.lastIndexOf(","));
        ids=" and I_INFO not in("+ids+")";
    }


    //将YW_ID组成一个'YW_ID',字符串
    //将datagrid 获取到后 就用变量存起来,不然每次 jquery 获取都是一次耗时操作
    var queryDG=$('#'+prefix+"_"+resultDG);
    queryDG.datagrid({
        idField:"I_INFO",
        pageNumber:1,
        pagination:true,
        pageList:[300],
        url:_m_url+'framework/loadDataQ',
        queryParams:{'dsId':dsId,'config':useConf,"originalSql":ids}
    });
}

/**
 * 弹窗的确定按钮
 *
 * @return
 */
function cbsfpd_sure1(){
    // 关闭弹窗
    $('#cbst_DATA_PARENT_PANEL').window('close');
    // 原有明细数据
    var oldRows = $('#cbsfpd_addItemDatagrid').datagrid('getRows');
    // 获取选择的数据
    var selRows = $('#cbst_DATA_DATALIST').datagrid('getSelections');

    // 关闭弹出窗口的editor
    for(var i=0;i<selRows.length;i++){
        var index=$('#cbst_DATA_DATALIST').datagrid("getRowIndex",selRows[i]);
        $('#cbst_DATA_DATALIST').datagrid('endEdit',index);
    }

    for ( var j = 0; j < selRows.length; j++) {
        $('#cbsfpd_addItemDatagrid').datagrid('appendRow', {
            VERIFY_DATE:selRows[j].VERIFY_DATE,
            DJ_CODE:selRows[j].DJ_CODE,
            REAL_MONEY :selRows[j].REAL_MONEY,
            MEMO:selRows[j].MEMO,
            I_INFO:selRows[j].I_INFO

        });
    }
}

/**
 * 出版社发票单的删除明细的按钮
 */
function deleteDZCL(obj,dgUrl,queryParams){
    // 获取选中的行
    var oldRows = $('#cbsfpd_addItemDatagrid').datagrid('getSelections');
    for(var i=0;i<oldRows.length;i++){
        var rowIndex= $('#cbsfpd_addItemDatagrid').datagrid('getRowIndex',oldRows[i]);
        $('#cbsfpd_addItemDatagrid').datagrid('deleteRow',rowIndex);
    }
}





